﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NetworkLib.Utilities;
using PBO.Network;

namespace PokemonBattle.BattleRoom.Server
{
    public class User : DataByteArray
    {
        public int Identity { get; set; }
        public string Name { get; set; }
        public UserState State { get; set; }
        public string Address { get; set; }
        public byte ImageKey { get; set; }
        public string CustomDataInfo { get; set; }
        public string CustomDataHash { get; set; }

        #region abstract

        public override void Read(ByteArray byteArray)
        {
            Identity = byteArray.ReadInt();
            Name = byteArray.ReadUTF();
            State = UserStateHelper.Parse(byteArray.ReadInt());
            Address = byteArray.ReadUTF();
            ImageKey = byteArray.ReadByte();
            CustomDataInfo = byteArray.ReadUTF();
            CustomDataHash = byteArray.ReadUTF();
        }

        public override void Write(ByteArray byteArray)
        {
            byteArray.WriteInt(Identity);
            byteArray.WriteUTF(Name);
            byteArray.WriteInt((int)this.State);
            byteArray.WriteUTF(Address);
            byteArray.WriteByte(ImageKey);
            byteArray.WriteUTF(CustomDataInfo);
            byteArray.WriteUTF(CustomDataHash);
        }

        #endregion

    }
}
